@model EditTenantViewModel
@inject IEnumerable<OrchardCore.Data.DatabaseProvider> DatabaseProviders

<h1>@RenderTitleSegments(T["Edit Tenant"])</h1>

<div asp-validation-summary="ModelOnly"></div>
<form asp-action="Edit" method="post">

    <div class="form-group" asp-validation-class-for="Name">
        <label asp-for="Name">@T["Name"]</label>
        <input asp-for="Name" class="form-control" readonly autofocus />
        <span asp-validation-for="Name" class="text-danger"></span>
        <span class="hint">@T["The name of the tenant."]</span>
    </div>

    <div class="form-group" asp-validation-class-for="Description">
        <label asp-for="Description">@T["Description"]</label>
        <input asp-for="Description" class="form-control" autofocus />
        <span asp-validation-for="Description" class="text-danger"></span>
        <span class="hint">@T["The description of the tenant."]</span>
    </div>

    <div class="form-group" asp-validation-class-for="RequestUrlPrefix">
        <label asp-for="RequestUrlPrefix">@T["Url Prefix"]</label>
        <input asp-for="RequestUrlPrefix" class="form-control" autofocus />
        <span asp-validation-for="RequestUrlPrefix" class="text-danger"></span>
        <span class="hint">@T["(Optional) Example: If prefix is \"site1\", the tenant URL is \"https://orchardcore.net/site1\""]</span>
    </div>

    <div class="form-group" asp-validation-class-for="RequestUrlHost">
        <label asp-for="RequestUrlHost">@T["Hostname"]</label>
        <input asp-for="RequestUrlHost" class="form-control" autofocus />
        <span asp-validation-for="RequestUrlHost" class="text-danger"></span>
        <span class="hint">@T["Example: If host is \"orchardproject.net\", the tenant URL is \"https://orchardcore.net/\""]</span>
        <span class="hint">@T["You may define multiple domains using the comma (,) as a separator. Use the '*.' prefix to map all subdomains."]</span>
    </div>

    @if (Model.CanSetDatabasePresets)
    {
        <h6>
            @T["Recipe"]
            <span class="text-muted form-text small">@T["Optionally specify which presets should be used for the Setup experience."]</span>
        </h6>
        <div class="row recipes" asp-validation-class-for="RecipeName">
            <div class="form-group col-md-6">
                <select asp-for="RecipeName" class="form-control">

                    <option value=""></option>
                    @foreach (var recipe in Model.Recipes)
                    {
                        <option value="@recipe.Name" selected="@(Model.RecipeName == recipe.Name)">
                            @recipe.Name
                        </option>
                    }
                </select>
            </div>
        </div>

        <h6>
            @T["Database Presets"]
            <span class="text-muted form-text small">@T["Optionally specify which presets should be used for the Setup experience."]</span>
        </h6>
        <div class="row">
            <div class="form-group col-md-6">
                <label asp-for="DatabaseProvider">@T["What type of database to use?"]</label>
                <select asp-for="DatabaseProvider" class="form-control">
                    <option value="" data-connection-string="false">@T["None"]</option>
                    @foreach (var provider in DatabaseProviders)
                    {
                        <option value="@provider.Value" data-connection-string="@provider.HasConnectionString.ToString().ToLower()" data-table-prefix="@provider.HasTablePrefix.ToString().ToLower()">@provider.Name</option>
                    }
                </select>
            </div>
            <div class="form-group col-md-6" asp-validation-class-for="TablePrefix">
                <label asp-for="TablePrefix">@T["Table Prefix"]</label>
                <span asp-validation-for="TablePrefix" class="text-danger"></span>
                <input asp-for="TablePrefix" class="form-control" />
            </div>
        </div>

        <div class="row connectionString" asp-validation-class-for="ConnectionString">
            <div class="form-group col-md-12">
                <label asp-for="ConnectionString">@T["Connection string"]</label>
                <span asp-validation-for="ConnectionString" class="text-danger"></span>
                <input asp-for="ConnectionString" class="form-control" />
                <span class="text-muted form-text small">@T["The connection string to your database instance. e.g., Data Source=<em>localhost</em>;Initial Catalog=<em>Orchard</em>;User Id=<em>userid</em>;Password=<em>password</em>"]</span>
            </div>
        </div>
    }

    <div class="form-group">
        <button class="btn btn-primary" type="submit">@T["Save"]</button>
        <a class="btn btn-secondary" asp-route-action="Index">@T["Cancel"]</a>
    </div>
</form>

<script at="Foot" type="text/javascript" asp-src="~/OrchardCore.Tenants/Scripts/tenant.js" depends-on="jquery"></script>
